package com.sophialex.health.record.action;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.part.ViewPart;

import com.sophialex.health.common.platform.SuperContext;
import com.sophialex.health.person.vo.HrIssue;
import com.sophialex.health.person.vo.HrPerson;
import com.sophialex.health.record.Messages;
import com.sophialex.health.record.common.utils.ImageUtil;
import com.sophialex.health.record.dialog.HrIssueDialog;
import com.sophialex.health.record.views.PersonBottomLeftView;
import com.sophialex.health.system.frame.dialog.DialogManager;
import com.sophialex.health.system.lktable.LKTable;
/**
 * 问题目录操作类 --- 编辑
 * <p>Title:Health</p>
 * <p>HrIssueAction</p>
 * 
 * Alex Apr 18, 2011 9:09:17 PM create
 * @author <a href='wanghao924@126.com'>Alex</a>
 * QQ: 873987060;
 * @version 1.0
 */
public class HrIssueEditAction extends Action implements IWorkbenchAction {
    public static final String ID = "com.sophialex.health.record.action.HrIssueEditAction";
    
    private IWorkbenchWindow workbenchWindow;
    private LKTable lKTable;
    private PersonBottomLeftView view;
    
    public HrIssueEditAction(IWorkbenchWindow workbenchWindow,LKTable lKTable,PersonBottomLeftView view){
    	if(workbenchWindow==null){
    		throw new IllegalArgumentException();
    	}
    	this.lKTable = lKTable;
    	this.view = view;
    	this.workbenchWindow = workbenchWindow;
    	setId(ID);
    	setText(Messages.getString("HrIssueAction.1"));
    	setImageDescriptor(ImageUtil.edit_issue);
    }
    

	public void dispose() {
		workbenchWindow = null;
	}
	
	public void run(){
		if(workbenchWindow == null){
			return;
		}
		HrPerson currentPerson = SuperContext.currentPerson;
		if(currentPerson == null){
			DialogManager.invokeWarnDlg(Messages.getString("Common.12"));
			return;
		}
		if (lKTable.getSelection() != null) {
			HrIssue hrIssue = (HrIssue) lKTable.getSelection();
			HrIssueDialog dlg = new HrIssueDialog(hrIssue,workbenchWindow.getShell(), SWT.NONE);
			HrIssue t = (HrIssue) dlg.open();
			if(t!=null){
				view.refreshUpdate();
			}
			
		}else{
			DialogManager.invokeInfoDlg(Messages.getString("HrIssueInfo.0"));
		}
	}

}
